package com.example.springboot.jpa.controller;

import com.example.springboot.jpa.entity.User;
import com.example.springboot.jpa.service.UserService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;

/**
 * @desc
 * @Author wangsh
 * @date 2018/5/5 21:37
 */
@RestController
@RequestMapping("/jpa")
public class JpaController {

	@Resource
	private UserService userService;


	@RequestMapping("/save")
	public void save() {
		User user = new User();
		user.setUserName("zhangsan");
		user.setPassword("123");

		userService.save(user);
	}

	@RequestMapping("/findByUserName")
	public User findByUserName(String userName) {
		User user = userService.findByUserName(userName);
		System.out.println(user);
		return user;
	}

	@RequestMapping("/findByUserName2")
	public User findByUserName2(String userName) {
		User user = userService.findByUserName2(userName);
		System.out.println(user);
		return user;
	}

}

